﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Epi;
using CDC.SampleShell.Infrastructure;

namespace CDC.SampleShell.Domain
{
    public sealed class Record : Entity
    {
        private bool _isLocked = false;
        public bool IsLocked { get { return _isLocked; } set { _isLocked = value; } }

        public Record(Entity record)
            : base(record)
        {

        }

        public Record(Guid id, View form)
            : base(id, form)
        {

        }

        public Record(Guid id, View form, Entity parent)
            : base(id, form, parent)
        {
            
        }

        public void Lock()
        {
            if (Locked != null)
            {
                Locked(this, new EventArgs());
            }
            IsLocked = true;
        }

        public void Unlock()
        {
            if (Unlocked != null)
            {
                Unlocked(this, new EventArgs());
            }
            IsLocked = false;
        }

        public event EventHandler Locked;
        public event EventHandler Unlocked;
    }
}
